22 #include "event_groups.h" 25 #include "fsl_debug_console.h" 29 #include "clock_config.h" 33 #include "fsl_i2c_cmsis.h" 34 #include "fsl_dspi_cmsis.h" 45 .functionParam = NULL,
68 static void read_task(
void *pvParameters);
69 static void fusion_task(
void *pvParameters);
84 I2Cdrv->PowerControl(ARM_POWER_FULL);
85 I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
97 xTaskCreate(read_task,
"READ", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL);
98 xTaskCreate(fusion_task,
"FUSION", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL);
101 vTaskStartScheduler();
106 static void read_task(
void *pvParameters)
109 portTickType lastWakeTime;
110 const portTickType frequency = 1;
111 lastWakeTime = xTaskGetTickCount();
115 vTaskDelayUntil(&lastWakeTime, frequency);
122 static void fusion_task(
void *pvParameters)
125 float motion_baseline[3] = {0.0, 0.0, 0.0};
127 static bool lastStationary;
128 uint32_t stationaryCount = 0;
149 if (!lastStationary) {
155 if (lastStationary) {
177 lastStationary = stationary;
ControlSubsystem controlSubsystem
used for serial communications
readSensors_t * readSensors
read all physical sensors
This structure defines the device specific info required by register I/O.
initializeFusionEngine_t * initializeFusionEngine
set sensor fusion structures to initial values
#define I2C_S_SIGNAL_EVENT
Provides function prototypes for driver level interfaces.
An instance of PhysicalSensor structure type should be allocated for each physical sensors (combo dev...
setStatus_t * queueStatus
queue status change for next regular interval
int8_t MAG3110_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
int8_t FXLS8952_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
#define BOARD_BootClockRUN
int8_t MAG3110_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
int main(void)
This is a FreeRTOS (dual task) implementation of the NXP sensor fusion demo build.
Application-specific status subsystem.
conditionSensorReadings_t * conditionSensorReadings
preprocessing step for sensor fusion
Defines control sub-system.
The top level fusion structure.
void BOARD_InitDebugConsole(void)
void initSensorFusionGlobals(SensorFusionGlobals *sfg, StatusSubsystem *pStatusSubsystem, ControlSubsystem *pControlSubsystem)
utility function to insert default values in the top level structure
struct PhysicalSensor sensors[3]
This implementation uses three physical sensors.
int8_t FXAS21002_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
The register_io_i2c.h file declares low-level interface functions for reading and writing sensor regi...
he ControlSubsystem encapsulates command and data streaming functions.
StatusSubsystem statusSubsystem
provides visual (usually LED) status indicator
runFusion_t * runFusion
run the fusion routines
#define FXAS21002_I2C_ADDR
Non-recoverable FAULT = something went very wrong.
registerDeviceInfo_t i2cBusInfo
The sensor_fusion.h file implements the top level programming interface.
SensorFusionGlobals sfg
This is the primary sensor fusion data structure.
setStatus_t * setStatus
change status indicator immediately
int8_t FXAS21002_Idle(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
uint8_t sUARTOutputBuffer[256]
main output buffer defined in control.c
updateStatus_t * updateStatus
status=next status
bool motionCheck(float sample[3], float baseline[3], float tolerance, uint32_t winLength, uint32_t *count)
installSensor_t * installSensor
function for installing a new sensor into t
struct ControlSubsystem * pControlSubsystem
int8_t FXLS8952_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
EventGroupHandle_t event_group
void vApplicationTickHook(void)
int8_t initializeControlPort(ControlSubsystem *pComm)
Initialize the control subsystem and all related hardware.
Running in reduced power mode.
void vApplicationIdleHook(void)
clearFIFOs_t * clearFIFOs
clear sensor FIFOs
int8_t FXAS21002_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
#define FXLS8952C_I2C_ADDR
void initializeStatusSubsystem(StatusSubsystem *pStatus)
#define I2C_S_DEVICE_INDEX
int8_t MAG3110_Idle(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
streamData_t * stream
function to create packets for serial stream
Lower level sensor fusion interface.
applyPerturbation_t * applyPerturbation
apply step function for testing purposes
StatusSubsystem() provides an object-like interface for communicating status to the user...
int32_t loopcounter
counter incrementing each iteration of sensor fusion (typically 25Hz)